<ul class="list-cmts">
    @if(!is_null($data['answer']))
    @foreach( $data['answer'] as $answer)
    <li>
        <div class="lf-avatar">
            <a href="#"><img src="../images/avatar2.jpg" alt=""></a>
        </div>
        <div class="lr-content">
            <div>
                <a href="#" class="font-Bold colorDackG">{{$answer->username}}</a>
                <span class="font11 color66">GURU - Đệm hát</span>
            </div>
            <div>{{$answer->content}}</div>
            <div>
                <span class="likeanswer{{$answer->id}} font11 color66">{{$answer->votes}} lượt thích</span>
                <a class="clicklikeanswer colorDackG" href="{{$answer->id}}" >Thích</a>
            </div>
        </div>
    </li>
    @endforeach

</ul>
@if(count($data['answer'])> 0)
<div class="div_p"> <?php
    Paginator::setPageName('page');
    echo $data['answer']->links();
    ?>
</div>
@endif
@if(count($data['answer'])== 0)
<div class="div_p">Chưa có câu trả lời nào !!!</div>
@endif
@endif
<ul class="list-cmts">
    <form id="answer-form" method="post">
        <li style="border-bottom: none">
            <div class="lf-avatar" style="top:0">
                <a href="#"><img src="../images/avatar2.jpg" alt=""></a>
            </div>
            <div class="areatxt_1" style="padding:0">
                <div class="txt-lf">
                    <textarea name="content" placeholder="<?= $errors->first('content', ':message') ?>"></textarea>
                </div>
                <div class="txt-lr">
                    <input type="submit" value="gửi" name="gửi">
                </div>
            </div>
        </li>
    </form>
</ul>
<script>

    $(document).ready(function () {
        $(document).on('click', '.clicklikeanswer', function (e) {
            getVoteAnswer($(this).attr('href'))
            e.preventDefault();
        });
    });
    function getVoteAnswer(id) {
        $.ajax({
            type:'POST',
            url: '<?=route('hoi-dap')?>/addlike?voteanswer=' + id,
            dataType: 'json',
        }).done(function (data) {
            $('.likeanswer' + id).html(data);
        }).fail(function () {
            alert('Posts could not be loaded.');
        });


    }

</script>